package mmc;

import static mmc.util.Utils.*;
import static org.lwjgl.opengl.GL11.*;
import mmc.server.Server;

@SuppressWarnings("serial")
public class Light extends MovableEngineObject{
	
	private static int lightCount=0;
	public final int lightId;
	
	public Light(float x, float y, float z, float vx, float vy, float vz){
		this(x,y,z);
		this.vx = vx;
		this.vy = vy;
		this.vz = vz;
	}
	
	public Light(float x, float y, float z) {
		super(x, y, z);
		lightId = setupLightId();
	}

	public void updateLightPosition(){
		glLight(lightId, GL_POSITION, wrap4f(x,y,z,1));
	}
	
	@Override
	public void render(EngineObject observer) {
		
	}

	@Override
	public void update(float dt) {
		
	}
	
	private synchronized int setupLightId(){
		switch(lightCount++){
			case 0:  return GL_LIGHT0;
			case 1:  return GL_LIGHT1;
			case 2:  return GL_LIGHT2;
			case 3:  return GL_LIGHT3;
			default: throw new RuntimeException("too many lights!");
		}
	}

	@Override
	public void update(Server server, float dt) {
		// TODO Auto-generated method stub
		
	}
	
}
